package com.sgb.member.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemPersonApplyRecordBinding;
import com.sgb.member.entity.MemberPersonBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.StringUtil;

import java.util.List;

public abstract class PersonApplyRecordAdapter extends BaseRecycleAdapter<MemberPersonBean> {

    private final int mCurPage;

    public PersonApplyRecordAdapter(Context context, List<MemberPersonBean> datas, int curPage) {
        super(context, R.layout.item_person_apply_record, datas);
        mCurPage = curPage;
    }
    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        String companyLogo = datas.get(position).companyLogo;
        ImageView quality_member_logo = holder.itemView.findViewById(R.id.quality_member_logo);
        Glide.with(context).load(companyLogo).placeholder(R.drawable.member_icon_company_logo).error(R.drawable.member_icon_company_logo).into(quality_member_logo);
    }
    @Override
    public void convert(ItemViewHolder holder, final MemberPersonBean entity) {
        holder.setBinding(BR.viewModel, entity);
        holder.setBinding(BR.curPage, mCurPage);
        ItemPersonApplyRecordBinding binding = (ItemPersonApplyRecordBinding) holder.getmBinding();
        binding.tvInvite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                againInvite(entity);
            }
        });
        binding.tvInvite.setVisibility(View.GONE);
        // status 状态1.待处理2.通过3.拒绝
        switch (entity.status) {
            case 1:
                binding.ivStatus.setImageResource(R.mipmap.member_icon_dsh);
                break;
            case 2:
                binding.ivStatus.setImageResource(R.mipmap.member_icon_passed);
                break;
            case 3:
                binding.ivStatus.setImageResource(R.mipmap.member_icon_wtg);
                binding.tvInvite.setVisibility(View.VISIBLE);
                break;
        }
        /*if (!StringUtil.isEmpty(entity.businessAddress)) {
            binding.qualityMemberAddress.setText(entity.businessAddress);
        } else {
            String address = StringUtil.getNotEmptyStr(entity.provinceName) +
                    StringUtil.getNotEmptyStr(entity.cityName) + StringUtil.getNotEmptyStr(entity.areaName);
            binding.qualityMemberAddress.setText(address);
        }*/
    }

    protected abstract void againInvite(MemberPersonBean entity);

}
